<template>
  <div class="post-list">
    <!-- <article v-for="post in posts" :key="post._id" class="card mb-3 shadow-sm">
      <div class="card-body">
        <h4>{{post.title}}</h4>
        <div class="row my-3 align-items-center">
          <div class="col-3" v-if="post.avatar?.url">
            <img :src="post.avatar.url" :alt="post.avatar.filename" class="rounded-lg">
          </div>
          <p :class="{ 'col-9': post.avatar?.url }">{{post.description}}</p>
        </div>
        <span class="text-muted">{{post.createdAt}}</span>
      </div>
    </article> -->
    <article class="card mb-3 shadow-sm">
      <div class="card-body" style="max-height: 300px;">
        <h4>{{list.title}}</h4>
        <div class="row my-3 align-items-center">
          <div class="col-3" v-if="list.avatar.url">
            <img :src="list.avatar.url" :alt="list.avatar.filename" class="rounded-lg" style="height: 200px;">
          </div>
          <p :class="{ 'col-9': list.avatar.url }">{{ list.description }}</p>
        </div>
        <span class="text-muted">{{ list.createdAt }}</span>
      </div>
    </article>
  </div>
</template>

<script lang="ts">
import { defineComponent, PropType, computed, reactive, onMounted, onBeforeMount } from 'vue'
import { PostProps } from '@/hooks/testData'
import { useStore } from 'vuex'
export default defineComponent({
  name: 'PostList',
  props: [
    'list'
  ],
  setup() {
    const store = useStore()

    const posts: PostProps[] = []
    onBeforeMount(() => {
      const post: PostProps = store.state.posts
      // console.log(post)
      posts.push(post)
    })
    return {
      posts
    }
  },
})
</script>
